﻿import fetch from 'utils/fetch';


//
export function getUserInfoDetail() {
    const data = {};
    return fetch({
        url: '/education/getUserInfoDetail',
        method: 'post',
        data
    });
}
// edit by cuihd at 20180710 删除了参数uesrId
// 查询对应的年级 ---- 班主任 
export function getGradeInfoByUserIdAndSchoolId(schoolId) {
    const data = {
        schoolId
    };
    return fetch({
        url: '/student/getGradeInfoByUserIdAndSchoolId',
        method: 'post',
        data
    });
}

// 查询对应的班级 ---- 班主任
export function getClassInfoList(gradeId, schoolId) {
    const data = {
        gradeId,
        schoolId
    };
    return fetch({
        url: '/student/getClassInfoByUserIdAndSchoolIdAndGradeId',
        method: 'post',
        data
    });
}


// 获取学校列表
export function getLoginRoleInfo(userId) {
    const data = {
        userId
    };
    return fetch({
        url: '/student/getLoginRoleInfo',
        method: 'post',
        data
    });
}

// 获取年级  
export function getGradeList(schoolId) {
    const data = {
        schoolId
    };
    return fetch({
        url: '/student/getGradeBySchoolId',
        method: 'post',
        data
    });
}

// 获取班级
export function getClassList(gradeId, schoolId) {
    const data = {
        gradeId,
        schoolId
    };
    return fetch({
        url: '/student/getClassByGrade',
        method: 'post',
        data
    });
}

// 新增学生
export function addStudent(userId, schoolId, schoolName, gradeId, classId, studentName, studentSex, schoolrollCode, birthDay, parentPhone, phones) {
    const data = {
        /**
         * 创建人ID
         */
        userId,
        /**
         * 所属学校id
         */
        schoolId,
        schoolName,
        /**
         * 年级
         */
        gradeId,
        /**
         * 班级编号
         */
        classId,
        /**
         * 学生姓名
         */
        studentName,
        /**
         * 性别
         */
        studentSex,
        /**
         * 学籍号
         */
        schoolrollCode,
        /**
         * 生日
         */
        birthDay,
        /**
         * 家长号码
         */
        parentPhone,
        phones

    };
    return fetch({
        url: '/student/saveStudentInfo',
        method: 'post',
        data
    });
}

// 初始化学生密码
export function initializePassword(studentId) {
    const data = {
        studentId
    };
    return fetch({
        url: '/student/initializePassword',
        method: 'post',
        data
    });
}

// 删除学生
export function deleteBatchStudentInfo(studentId, schoolId, schoolName) {
    const data = {
        studentId,
        schoolId,
        schoolName
    };
    return fetch({
        url: '/student/deleteBatchStudentInfo',
        method: 'post',
        data
    });
}

// 批量删除学生轮询接口
export function deleteBatchStudentInfoProgress(timeStamp) {
    const data = {
        timeStamp
    };
    return fetch({
        url: '/student/deleteBatchStudentInfoProgress',
        method: 'post',
        data
    });
}

// 添加班级
export function insertClassInfo(userId, studentId, schoolId, schoolName, grade, classId) {
    const data = {
        /**
         * 用户ID
         */
        userId,
        studentId,
        /**
         * 所属学校id
         */
        schoolId,
        /**
         * 所属学校名称
         */
        schoolName,
        /**
         * 年级
         */
        grade,
        /**
         * 班级编号
         */
        classId
    };
    return fetch({
        url: '/student/insertClassInfo',
        method: 'post',
        data
    });
}

// 查询学生信息分页
export function getStudentList(curPage, pageSize, schoolId, grade, classId, eId, studentName, parentPhone) {
    const data = {
        schoolId,
        grade, // 年级
        classId, // 班级
        eId, // exueid
        studentName, // 学生名称
        parentPhone
    };
    return fetch({
        url: `/student/getStudentInfo/${curPage}/${pageSize}`,
        method: 'post',
        data
    });
}

// 5. 查看学生信息
export function getStudentRelativeInfo(studentId) {
    const data = {
        studentId
    };
    return fetch({
        url: '/student/getStudentRelativeInfo',
        method: 'post',
        data
    });
}

// 6. 获取学生当前班级分页信息
export function getStudentInfo(curPage, pageSize, studentId, schoolId) {
    const data = {
        studentId,
        schoolId
    };
    return fetch({
        url: `/student/getPresentClassInfo/${curPage}/${pageSize}`,
        method: 'post',
        data
    });
}

// 7. 获取学生历史班级分页信息
export function getHistoryClassInfo(curPage, pageSize, studentId, schoolId) {
    const data = {
        studentId,
        schoolId
    };
    return fetch({
        url: `/student/getHistoryClassInfo/${curPage}/${pageSize}`,
        method: 'post',
        data
    });
}

// 9. 相关学生当前班级编辑信息
export function updateStudentClassInfo(classId, honor, buesiness, studentId) {
    const data = {
        classId,
        honor,
        buesiness,
        studentId
    };
    return fetch({
        url: '/student/updateStudentClassInfo',
        method: 'post',
        data
    });
}

// 学校列表
export function querySchoolByName(schoolName) {
    const params = {
        schoolName
    };
    return fetch({
        url: '/teacher/querySchoolByName',
        method: 'get',
        params
    });
}

// 年级列表
export function getGrade(periodId, year) {
    const data = {
        periodId,
        year
    };
    return fetch({
        url: '/teacher/getGradeBySchool',
        method: 'post',
        data
    });
}

// 班级列表
export function getClass(grade, schoolId) {
    const data = {
        grade,
        schoolId
    };
    return fetch({
        url: '/teacher/getClassByGrade',
        method: 'post',
        data
    });
}

// 获取户口性质
export function getAccountsNatureInfo() {
    const data = {

    };
    return fetch({
        url: '/student/getAccountsNatureInfo',
        method: 'post',
        data
    });
}

// 编辑学生信息
export function updateLookStudentInfo(studentId, studentName, studentSex, schoolRollCode, birthDay,
    accountNature, provinceId, cityId, areaId, provinceName, cityName, areaName, email, postalCode, workCode, presentAddress, homeAddress, phones) {
    const data = {

        studentId, // 学生id
        studentName, // 学生姓名
        studentSex, // 学生性别
        schoolRollCode, // 学籍号
        birthDay, // 出生年月
        accountNature, // 户口性质
        provinceId, // 学生所属省id
        cityId, // 学生所属市id
        areaId, // 学生所属区id
        provinceName, // 省名称
        cityName, // 市名称
        areaName, // areaName
        email, // 电子邮箱
        postalCode, // 邮政编码
        workCode, // 考勤卡号（暂时没有）
        presentAddress, // 现住地址
        homeAddress, // 家庭地址
        phones

    };
    return fetch({
        url: '/student/updateLookStudentInfo',
        method: 'post',
        data
    });
}

// 解除学生家长关系
export function relieveStudentParentRelative(studentId, parentExueCode) {
    const data = {
        studentId, // "学生id"  必填项
        parentExueCode // "家长e学云ID号"  必填项        
    };
    return fetch({
        url: '/student/relieveStudentParentRelative',
        method: 'post',
        data
    });
}

// 学生管理-删除学生联系人
export function removeStudentPhoneMap(status, studentId, phone) {
    const data = {
        status,
        studentId, 
        phone        
    };
    return fetch({
        url: '/student/removeStudentPhoneMap',
        method: 'post',
        data
    });
}